package com.gs.common.tool.utils;

/**
 * 操作系统工具类
 *
 * @author guoshuai
 * @date 2024/05/27 09:25
 **/
public class OsUtil {

    public static final String WINDOWS_FILE_SEP = "\\\\";

    public static final String LINUX_FILE_SEP = "/";

    private static final String OS_NAME;

    static {
        OS_NAME = System.getProperty("os.name").toLowerCase();
        System.out.println(OS_NAME);
    }

    public static boolean isWindows() {
        return OS_NAME.contains("win");
    }

    public static String getFileSep() {
        return isWindows() ? WINDOWS_FILE_SEP : LINUX_FILE_SEP;
    }

    public static boolean isMac() {
        return OS_NAME.contains("mac");
    }

    public static String castPath(String filePath) {
        if (isWindows()) {
            return filePath;
        }
        return filePath.replace("\\", "/");
    }
}
